better code, bugfix