Refactored Tjr's commit