restructure code to be neater and include object wrappers