simplifying my code