Removed some duplicate code