refactored this file further