assignment-1 -- better solution