Updated sendCommand() function to be quicker & cleaned up code