working version without error in console