Port macro to private method
The macro was a bit confusing, now it's clear when each function returns.