Fixing wrong logic and formatting described in #66 ticket