made code nicer with comments, formatting and flowers