commiting solution. need to figure out the complexity