fixed problem withg nil in sp