Move wait method to Utils.java

Move wait method to Utils.java for more flexability.