edit according to edge cases
sol of q080