evolved code, merged with last brackets-git