running version, needs to be cleaned and refactored.