Added user commands and refactored common code for readbility