Cleaned up code, explained prinout in comments