cleaned up limit_fn marginally