fixed a few niggles in the provided implementation