code tidy and removed debugging lines