Update fields.py

Move helper function to the top