updated with working version