improved the barrier test function