Implemented solutions and helper functions