finished fixing all functionalities