small changes to code structure

Added test to see if this is a function