removed unnecessary min and max functions