cast return values to proper instances