Correcting misspelt command, fixing code repetition