cleaned up and new code