re-added lines from commit fb84aaf9bccdd009123ba3c4628f47a407672ea8