cleaning the code and adding options