* no modifications here, just moved the code a bit