Slight refactorings and a syntax error fix
Add print statement