cleaned up the code
commented code better