Added edge case check for val