Removed some duplicate code
Removed some duplicate code