merged with jasons code