Fix code to more consise structure