cleaned up code, removed logging