changed loop to use key() and next() instead of foreach
changed return type of get_by_id to static[]