updated for new calling conventions