cleaned up somewhat