added mathematical solution