got rid of some duplicate code