refactored the implementations to be shorter and more concise