Updating randpos function