code refactored still works the same, but shorter