fixed issues with code that neardark found