bug fixes and tested upper and lower bound functions