cleaned up code and comenting