If x is approaching one of the transition points of the function, then you have to check both  limit.

Algebraic Limit-1

Limit for Piecewise function