Functions refactoring done