Refactoring: added functions instead of calls, added constants