performance improvement + bugfix