Modified temp function, added some tests