fixed significant bug (thanks @plannapus)