better code, still doesn't work