refactoring to be more swifty