Updated code to automatically take photos