clean up code
Fix bug