cleaned up and functional