Reduced code functions and remove some code