added waitbar and fixed some code