Removed redundant code to make it more effecient.