removing some duplicate code