Fixing bug.. needs rebasing