Fix undefined position bug