NullPointerException in calendar solved. Now it's stuck in a loop