re-implementation of 500, in python