Help me optimize this function

Printable View