Added snap function.