added waitready function