minor bug fixing, still work in progress