Fixed bug caused by legacy code