Reorganized functions and added command