completly redisigned code

wrote code from the ground up for a new design and more coherent
structure