Fixed implicit cast as it can cause exceptions later on