Fixed Bug in Core Funtion