ADded general functions correctly this time.