better code, much more comments