some minor refactoring that makes the code more easily understanding