fix moved into if block