cleaned up the code and added in the endpoints