adding documentation, and better input handling