extended and commented code