refactored for maintainablity