code refactor for easy reading