fix scan function
add goaldistance function
add checkmovement function