Did the second homework task (for lectures). It works perfectly, exactly as it should! Also, some other things may have been modified.