Fixing conditionals and bounds in functions