Made lots of changes to make it easier to implement