borrowed processing and utility functions from old SmarterBoard repo