cleaned up code
todo implement tests