refactored to prettier code