logic works, need to merge in database