Added comments and improved control flow /UI