Refactored towards better readability