checked working

test done- all working
shortened code