fixed [] method errors by using unless instead of if condition