Removed duplicate and redundant code

Should test