working version with unacceptable code quality