move to top-level function

Signed-off-by: Stephen Gran <stephen.gran@piksel.com>