more refactoring
refactored further based on github comments