more comments and cleaner code