updated to use values in head instead of guards