credit MrEngineer and fix sample