replace hacky bugfix with a clean one