edited lower and upper functions