refactor functions to make hands & add comments