refactoring to have more readable code