Updated Code for better debugging

Added some console log commands so we can see where errors occur