cleaned up missing code and bugs