Made homework handle more cases