removed some duplicate code