removed redundant code & added more tests