fixed bugs introduced in previous commit