cleaning up code, rearranging order of requests