separated ret into separate function