Added helper functions and removed debug messages