fixing minor issues
removed useless state
reorganized code