revert 56b46c2 and condense code