Almost working implementation for 5b