Rearranged the code, implemented a proper framework for implementing commands