added category detection by array index lookup
cleaned up functions, made sure all global functions were in the global App object