cleaned up the function defs