Commented code and fixed bug