refactored more code