Fixed a bug caused by a refactor