Added comments and on_pass_func improved