big update, less code, more powerful