cleaned up syntactically, removed print statements