reduce complexity of escape function