implemented motor and randmoizaton