You do not need to switch presentations: using the proper var does that. Your old logic (with my changes) was better. Exactly what line gave the error on my version? Oh, and print out $k and $slideindex to be sure they are right and to figure when the error occurs.