cleaned up comments and fixed bug