fixes issue #6. merged callado4's fix