refactored to use as many constants as possible