Removed printf and fixed bug