cleaning up and commenting backend code