Move ready function to bottom