Added Random Mode

Added random mode and fix some errors