Moved function outside