confirmed working example with bugs