working version but needs work