working local version after some bugs