reorganized into printCommand function, made all other functions a subfunction of it