encapsulated a lot of functionality, make better