Added respond function and moved a lot of things around to make it more organized.