Fixed a logic bug in the last commit