Added function to record image