cleaned up some of the indentation and unused code, should be finalized