Refactor to more understandable code