amended takePicture.js