move functions out of render