all functions working - needs to be cleaned up