fixes the bug, simplifies code