cleaned up code in core.rs