made the code look a little nicer - still not fully working but better abstraction