moved context to front of functions/routines