made casts explicit to avoid potential issues