Implemented solutions and helper fucntions